package com.xc.hotelmgr.datahandlermt.utils;

import com.xc.hotelmgr.datahandlermt.pojo.mybatis.OpTaskDetail;
import com.xc.hotelmgr.datahandlermt.service.mybatis.OpTaskDetailService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

@Service
public class SaveErrId {
    /**
     * 保存错误的酒店id*/
    @Autowired
    private OpTaskDetailService opTaskDetailService;

    public void saveIDList(List<Long> mtCodes,Long TaskId,String message){
        List<OpTaskDetail> opTaskDetailList = new ArrayList<>();
        for (Long hotelId:mtCodes) {
            OpTaskDetail opTaskDetail = new OpTaskDetail();
            opTaskDetail.setHotelId(hotelId);
            opTaskDetail.setTaskId(TaskId);
            opTaskDetail.setStatus((short) 0);
            opTaskDetail.setReason(message);
            opTaskDetailList.add(opTaskDetail);
        }
        opTaskDetailService.saveOrUpdateBatch(opTaskDetailList);
    }
}

